﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
using Quellenverwaltung.Data.Source;
using Quellenverwaltung.Data.SRU;
using Quellenverwaltung.SRU;

namespace Quellenverwaltung.Entwicklungskomponenten
{
    public partial class SRUTestForm : Form
    {
        public SRUTestForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SRU.CQLBuilder cqlBuilder = new SRU.CQLBuilder();
            cqlBuilder.cqlTerms["pica.all"] = textBox1.Text;

            SRU.Service service = new SRU.Service("http://sru.gbv.de/gvk");
            service.sruRecordSchema = "mods";
            

            ServiceConsumer consumer = new ServiceConsumer(service);
            Sources response = consumer.Request(cqlBuilder);
            richTextBox1.Text = "requested";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SRU.Service service = new SRU.Service("http://sru.gbv.de/gvk");
            SRU.ServiceConsumer consumer = new SRU.ServiceConsumer(service);
            SRUService serviceDesc = consumer.RequestServiceSpecification();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SRUService service = new SRUService();
            service.IndexInfo = new List<Index>();
            Index index = new Index();
            index.Description = "desc";
            index.Name = "name";
            index.Set = "pica";
            service.IndexInfo.Add(index);


            XmlSerializer serializer = new XmlSerializer(typeof(SRUService));
            TextWriter textWriter = new StreamWriter(@"I:\ServiceDesc.xml");
            serializer.Serialize(textWriter, service);
            textWriter.Close();
        }
    }
}
